//package com.demo.poi;
//
//import org.apache.poi.hssf.usermodel.HSSFRow;
//import org.apache.poi.hssf.usermodel.HSSFSheet;
//import org.apache.poi.hssf.usermodel.HSSFWorkbook;
//import org.apache.poi.ss.usermodel.*;
//import org.apache.poi.xssf.usermodel.XSSFWorkbook;
//import org.joda.time.DateTime;
//import org.junit.Test;
//
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
//import java.io.IOException;
//import java.util.Date;
//
///**
// * @Author: yuxuepeng.com
// * @Description:
// * @Date: Created in 10:38 2022-5-15
// * @Modified By:
// */
//public class DemoReadPOI01 {
//    @Test
//    public void testRead03() throws IOException {
//        String PATH = "D:\\xiangmu\\demo-poi\\";
//        //获取文件流
//        FileInputStream fileInputStream = new FileInputStream(PATH + "测试个表格2003.xls");
//        //1.创建一个工作簿。使用excel能操作的这边都可以操作
//        Workbook workbook = new HSSFWorkbook(fileInputStream);
//        //2.得到表
//        Sheet sheet = workbook.getSheet("测试Excel");
//        //3.得到行
//        Row row = sheet.getRow(1);
//        //4.得到列
//        Cell cell = row.getCell(0);
//        //读取值的时候，一定需要注意类型
//        //getStringCellValue 字符串类型
//        System.out.println(cell.getStringCellValue());
//        fileInputStream.close();
//    }
//
//    @Test
//    public void testRead07() throws IOException {
//        String PATH = "D:\\xiangmu\\demo-poi\\";
//        //获取文件流
//        FileInputStream fileInputStream = new FileInputStream(PATH + "测试个表格2007.xlsx");
//        //1.创建一个工作簿。使用excel能操作的这边都可以操作
//        Workbook workbook = new XSSFWorkbook(fileInputStream);
//        //2.得到表
//        Sheet sheet = workbook.getSheet("测试Excel");
//        //3.得到行
//        Row row = sheet.getRow(1);
//        //4.得到列
//        Cell cell = row.getCell(0);
//        //读取值的时候，一定需要注意类型
//        //getStringCellValue 字符串类型
//        System.out.println(cell.getStringCellValue());
//        fileInputStream.close();
//    }
//    @Test
//    public void testRead03All() throws IOException {
//        String PATH = "D:\\xiangmu\\demo-poi";
//        FileInputStream fileInputStream = new FileInputStream(PATH+"\\测试个表格2003.xls");
//        Workbook sheets = new HSSFWorkbook(fileInputStream);
//        Sheet demoData = sheets.getSheet("DemoData");
//        Row row = demoData.getRow(0);
//        if(row!=null){
//            int physicalNumberOfCells = row.getPhysicalNumberOfCells();
//            for (int cellIndex=0;cellIndex<physicalNumberOfCells;cellIndex++){
//                Cell cell = row.getCell(cellIndex);
//                String stringCellValue = cell.getStringCellValue();
//                System.out.print(stringCellValue+ " | " );
//            }
//        }
//        System.out.println();
//        int rowCount = demoData.getPhysicalNumberOfRows();
//        for (int rowIndex = 1;rowIndex<rowCount;rowIndex++){
//            Row rowData = demoData.getRow(rowIndex);
//            if (rowData!=null){
//                int cellCount = rowData.getPhysicalNumberOfCells();
//                for (int cellIndex = 0; cellIndex<cellCount;cellIndex++){
//                    Cell cell = rowData.getCell(cellIndex);
//                    System.out.print("["+(rowIndex+1)+"-"+(cellIndex+1)+"]");
//                    if (cell!=null){
//                        CellType cellType = cell.getCellType();
//                        String cellValue = "";
//                        switch (cellType){
//                            case BLANK:
//                                System.out.print("[blank]");
//                                break;
//                            case STRING:
//                                System.out.print("[String]");
//                                cellValue = cell.getStringCellValue();
//                                break;
//                            case BOOLEAN:
//                                System.out.print("[boolean]");
//                                cellValue = String.valueOf(cell.getBooleanCellValue());
//                                break;
////                            case FORMULA:
////                                System.out.println("[formula]");
////                                break;
//                            case NUMERIC:
//                                System.out.print("[numeric]");
//                                if(DateUtil.isCellDateFormatted(cell)){
//                                    Date dateCellValue = cell.getDateCellValue();
//                                    cellValue = new DateTime(dateCellValue).toString("yyyy-MM-dd");
//                                }else {
//                                    cell.setCellType(CellType.STRING);
//                                    cellValue = cell.toString();
//                                }
//                                break;
//                            case ERROR:
//                                System.out.println("[error]");
//                                break;
//                        }
//                        System.out.print("["+cellValue+"]\n");
//                    }
//                }
//            }
//        }
//        System.out.println();
//        System.out.println("over");
//        fileInputStream.close();
//    }
//}
